package com.see.front.view.staticdata;

import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.ui.AbstractSelect.Filtering;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
public class IndustryComboBox extends VerticalLayout implements Property.ValueChangeListener {

    private static final String[] cities = new String[] {"Copper", "Gold", "Personal Services"};

    public IndustryComboBox() {
        setSpacing(false);

        ComboBox box = new ComboBox("");
        box.setInputPrompt("Please select Industry");

        for (int i = 0; i < cities.length; i++) {
            box.addItem(cities[i]);
        }

        box.setFilteringMode(Filtering.FILTERINGMODE_OFF);
        box.setImmediate(true);
        box.addListener(this);

        addComponent(box);
    }

    /*
     * Shows a notification when a selection is made.
     */
    public void valueChange(ValueChangeEvent event) {
        getWindow().showNotification("Selected industry: " + event.getProperty());
        if (event.getProperty() != null) {
            TableLayout.loadFromDataSource(null, null, event.getProperty().toString());

        }

    }
}
